/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author SONY
 */
@Stateless
public class ProductFacade extends AbstractFacade<Product> implements ProductFacadeLocal {
    @PersistenceContext(unitName = "FashionShopEnterprise-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ProductFacade() {
        super(Product.class);
    }

    @Override
    public List<Product> findAll_LikePName(String pname) {
        List<Product> lstProducts = new ArrayList<Product>();
        try {
            lstProducts = getEntityManager().createNamedQuery("Product.findLikeProductName").setParameter("productName", pname).getResultList();
        } catch (Exception ex) {
            System.err.println(ex);
        }
        return lstProducts;
    }
    
}
